/**
 * 
 */
package com.mole.rbac.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.mole.rbac.entity.Course;
import com.mole.rbac.service.CourseService;
import com.mole.rbac.util.R;

/**
   *   说明：
 * @author maxin
 * @version 2019年9月28日上午9:40:55
 */
@RestController
@RequestMapping("/course")
public class CourseController {
	@Autowired
	private CourseService courseService;
	@PostMapping("save")
	public R save(@RequestBody Course course) {
		courseService.save(course);
		return R.ok() ;
	}
	@PostMapping("update")
	public R update(@RequestBody Course course) {
		courseService.update(course);
		return R.ok() ;
	}
	@GetMapping("deleteById")
	public R deleteById(Long id) {
		courseService.deleteById(id);
		return R.ok();
	}
	@GetMapping("getById")
	public R getById(Long id) {
		return R.ok().put("data", courseService.getById(id));
	}
	@GetMapping("listAll")
	public R listAll() {
		return R.ok().put("data", courseService.listAll());
	}
	@GetMapping("listByPage")
	public R listByPage(@RequestParam("pageIndex") Integer pageIndex, @RequestParam("pageSize") Integer pageSize) {
		return R.ok().put("data", courseService.listByPage(pageIndex, pageSize));
	}
}
